package com.study.handle;

import lombok.Builder;
import lombok.Data;

/**
 * @author ：ihao ∶）
 * @date ：Created in 2021-03-09 10:12
 */
@Data
@Builder
public class Result<T> {

    private int code;
    private T data;
    private String msg;

    public static <T> Result<T> success(T object) {
        return success(object, "成功");
    }

    public static <T> Result<T> success(T object, String msg) {
        return success(200, object, msg);
    }

    public static <T> Result<T> success(int code, T object, String msg) {
        return new Result<>(code, object, msg);
    }

    public static Result fail(String msg, int code) {
        return Result.builder().code(code).data(null).msg(msg).build();
    }
}
